package com.jia.springbootcontroller;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("test")
public class TestController {


    @PostMapping("testOne")
    public  Bean  getData(){

        Bean bean = new Bean();
        bean.setAddress("河南");
        bean.setName("zhangsan");
        return  bean;
    }

    @PostMapping("testSec")
    public  List<Bean>  getDatB(@RequestParam String name){
        System.out.println(name);
       List<Bean> Beans = new ArrayList<>();
        for (int i = 0; i <5 ; i++) {
            Bean bean = new Bean();
            bean.setAddress("河南"+i);
            if(i%2==0){
                bean.setName(name+"");
            }else {
                bean.setName(name+i+"");
            }

            Beans.add(bean);
        }
        return  Beans;
    }
}
